<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title></title>
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
</head>

<body>
    <div id="app">
        <ul>
            <!--  v-for="item in 数组名" 临时变量item就是每一个元素，item名字可自取 -->
            <li v-for="item in arr">{{item}}</li>
        </ul>
        <hr>

        <ul>
            <!--  v-for="item in 数组名" 临时变量item就是每一个元素，index对应就是下标 -->
            <li v-for="(item,index) in arr">{{item}}--{{index}}</li>
        </ul>
        <hr>

        <ul>
            <!-- 日常开发中我们得到的数组会更复杂 如果arr2 -->
            <li v-for="item in arr2">{{item.name}}的年龄是{{item.age}},性别是{{item.gender}}</li>
        </ul>
        <hr>

        <ul>
            <!--  v-for="(item,index) in 对象" 临时变量item对象值，index是键值 -->
            <li v-for="(item,index) in obj">{{index}} : {{item}}</li>
        </ul>
        <hr>

        <ul>
            <!--  遍历指定字符串(用得少)，字符串是伪数组所以也是可遍历的    -->
            <li v-for="(item,index) in str">{{item}} : {{index}}</li>
        </ul>
        <hr>

        <ul>
            <!--  遍历指定次数(用得少)  值是 1-5  索引是0-4 -->
            <li v-for="(item,index) in 5">{{item}} : {{index}}</li>
        </ul>
        <hr>
    </div>
    <script>
        new Vue({
            el: "#app",
            data: {
                arr: ["html", "css", "javascript", "jQuery", "Node"],
                obj: {
                    name: "Vue",
                    age: 7,
                    job: "web前端框架"
                },
                arr2: [{
                    name: "张三",
                    age: 16,
                    gender: "男"
                }, {
                    name: "李四",
                    age: 17,
                    gender: "女"
                }, {
                    name: "王五",
                    age: 20,
                    gender: "男"
                }],
                str: 'hello'
            }
        })
    </script>
</body>

</html>